package business;

import java.util.ArrayList;

import DAO.DAOException;
import DAO.EmployeeDAO;
import DAO.MySQL.EmployeeDAOImpl;
import Model.EmployeeBean;

public class EmployeeManager {
	public ArrayList<EmployeeBean> getEmployeeSummaryDetails() throws DAOException {
		ArrayList<EmployeeBean> employeeList = null;
		EmployeeDAO employeeDAO = null;
		try {
			employeeDAO = new EmployeeDAOImpl();
			employeeList = employeeDAO.getEmployeeSummaryDetails();
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return employeeList;
	}

	public EmployeeBean getEmployeeDetails( int employeeId) throws DAOException {
		EmployeeBean employeeDTO = null;
		EmployeeDAO employeeDAO = null;
		try {
			employeeDAO = new EmployeeDAOImpl();
			employeeDTO = employeeDAO.getEmployeeDetails( employeeId);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return employeeDTO;
	}
	
	public boolean updateEmployeeDetails(EmployeeBean employeeDTO) throws DAOException {
		boolean isUpdated = false ;
		EmployeeDAO employeeDAO = null;
		try {
			employeeDAO = new EmployeeDAOImpl();
			isUpdated = employeeDAO.updateEmployeeDetails( employeeDTO);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return isUpdated;
	}	

	public boolean deleteEmployeeDetails(int employeeId) throws DAOException {
		boolean isDeleted = false ;
		EmployeeDAO employeeDAO = null;
		try {
			employeeDAO = new EmployeeDAOImpl();
			isDeleted = employeeDAO.deleteEmployeeDetails( employeeId);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		return isDeleted;
	}	

}
